package c2b

import (
	"jlpay-sdk-go/pkg/jlpay/core"
	"jlpay-sdk-go/pkg/jlpay/models/trans/c2b"
	"jlpay-sdk-go/pkg/jlpay/services"
)

// QrcodePayService 二维码支付服务
type QrcodePayService struct {
	*services.BaseService
}

// NewQrcodePayService 创建二维码支付服务
func NewQrcodePayService(config *core.Config) *QrcodePayService {
	return &QrcodePayService{
		BaseService: services.NewBaseService(config),
	}
}

// QrcodePay 二维码支付
func (s *QrcodePayService) QrcodePay(request *c2b.QrcodePayRequest) (*c2b.QrcodePayResponse, error) {
	response := c2b.NewQrcodePayResponse()
	err := s.Post(request, response, "/open/trans/qrcodepay")
	if err != nil {
		return nil, err
	}
	return response, nil
}
